<?php 

namespace Acme\UserBundle\Form;
 
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

use Acme\UserBundle\Form\EventListener\AddNameFieldSubscriber;
 
class UserType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder->add('username', 'text', array('label' => '用户名'));
        $builder->add('password', 'repeated', array('type' => 'password', 'options' => array('label' => '设置密码'), 'invalid_message' => '两次输入密码不一致'));
        $builder->add('email', 'email', array('label' => '邮箱'));
    }
    
    // the name of the class that holds the underlying data(for use of function createForm)
    public function getDefaultOptions(array $options)
    {
		return array(
    				'data_class' => 'Acme\UserBundle\Entity\CmUser',
    				'validation_groups' => array('regist_default'),
    	);
    }
    
    // note that the getName() method should return a unique identifier for this form "type"
    public function getName()
    {
    	return 'user';
    }
}